package com.ruoyi.api.controller;

import com.ruoyi.api.domain.Merchant;
import com.ruoyi.api.service.IMerchantService;
import com.ruoyi.api.vo.MerchantVo;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 商家信息
 *
 * @author 寻觅
 * @since 2025-05-29
 */
@RestController
@RequestMapping("/merchant")
public class MerchantController extends BaseController {
    @Autowired
    IMerchantService merchantService;

    /**
     * 商家列表
     * @return
     */
    @PostMapping("/list")
    public TableDataInfo userList() {
        startPage();
        List<Merchant> list = merchantService.selectData();
        return getDataTable(list);
    }

    /**
     * 查询商家详情
     *
     * @param id
     * @return
     */
    @GetMapping("/info")
    public AjaxResult info(@RequestParam Long id) {
        return AjaxResult.success(merchantService.info(id));
    }

    /**
     * 查询商家交易记录
     *
     * @param id
     * @return
     */
    @GetMapping("/getTransactionRecords")
    public AjaxResult getTransactionRecords(@RequestParam Long id) {
        return AjaxResult.success(merchantService.getTransactionRecords(id));
    }

    /**
     * 查询商家和商品信息
     */
    @PostMapping("merchant/list")
    public TableDataInfo merchantList(){
    startPage();
    List<MerchantVo> list = merchantService.merchantList();
    return getDataTable(list);
}
}
